-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CIP-???? | Augment Spend Purpose #754
Conversation
This CIP synergizes well with the multi-validator trick and CIP-112. It would provide a large benefit to DApp throughput using current design patterns (withdraw-zero trick), that would transfer over directly to the equivalent pattern with observation scripts. I think this is a great idea. Personally, I would like to see this extended to: Where integer is the index of the input that is being spent in the |
I'm very happy with any use case which supersets the functionality I propose superseding this CIP! If we get the full input (as @MicroProofs wants), or we have minor adjustments on the first argument as you say, I'm happy. Frankly I'm moving away from any pattern which uses the spend validation directly in all my code so anything goes as long as the ScriptHash is somewhere in the constructor. |
+1 |
Hey @micahkendall, Since this proposal is currently very brief on all sections, I have converted it to a draft. |
What needs elaboration? |
cc @Ryun1 |
p.s. @micahkendall a good start would be to put all the things from this PR's OP into the proposal itself. My last answer was just to address the editing question directly. But you have some good detail in your original posting that answers a lot of these "elaboration" questions & would at least provide a starting point for proper review in the document itself. |
I think we should instead go for consistent integer indexes and fix #638 to get O(1) lookup in the inputs list. |
The point of the |
100% onboard with this. Would be an incredible improvement. |
If we're going to be getting O(1) lookup on inputs in time for Plutus V3 then I'm happy to withdraw this CIP. I think from a developer experience standpoint it's still sane to bring the information together, as it can hardly be considered random additional information when it is the exact information that every other script purpose variant contains. However to me that doesn't make it a meaningful improvement because I primarily care about performance. |
I think it's pretty unlikely that any further significant changes to the script context are going to hit PlutusV3, sorry. |
We should change the purpose Spend(OutputReference) to instead be Spend(x, ScriptHash)
EDIT: I have changed the proposal from Spend(OutputReference, ScriptHash) to Spend(x, ScriptHash), to indicate that this proposal is compatible with any changes to the first argument.
This would introduce asymptotic time savings for smart contracts using the pattern found in the Fortuna hard fork, or described in my blogpost. The cost to search the inputs list for an output reference, and then to find its address is fairly high in my personal benchmarking. Every other purpose exposes the script hash in some form, this unifies the ability of a script to know its own address (cheaply).
As an unverified, allegorical benchmark, we cut down from about 40k memunits per UTxO spent down to 14k memunits per UTxO spent by optimising around this limitation. We expect we could lift this limitation more with the acceptance of this CIP, and accomplish these numbers in an ergonomic, developer-friendly way.
Some different ways we currently optimise around this:
Rendered proposal on a author's fork